package com.oo.abstractAndInterface_6.atm;

import java.util.Scanner;

/**
 * CartTest--编写程序模拟处理银行ATM机的业务
 *
 * @author: Jovi
 * @createTime: 2017-03-24 16:56
 **/
public class CartTest {

    public static void main(String[] args) {

        /* Define the bank card and non the bank card */
        LocalCard localCard = new LocalCard("110", "1234", "jam", 1000);
        Nonlocal nonlocalCard = new Nonlocal("120", "1234", "daivd", 2000);

        /* Query non the bank card balance */
        System.out.println("Query non the bank：");
        System.out.println("Card number：" + nonlocalCard.getId() + "\nbalance" + nonlocalCard.getBalance());

        /* Non the bank draw money */
        System.out.println("Please enter the card debit amount：");
        Scanner input = new Scanner(System.in);
        double money = input.nextDouble();
        if (nonlocalCard.withdrawingMoney(money)) {
            System.out.println("Withdrawals success！the card balance is：" + nonlocalCard.getBalance());
        } else {
            System.out.println("Withdrawals failed！");
        }
        System.out.println("=====================================");

        /* Query the bank card balance */
        System.out.println("Query the bank card information：");
        System.out.println("The card number is ：" + localCard.getId() + "\nbalance is" + localCard.getBalance());

        /* The bank card withdrawals */
        System.out.println("Please enter the card debit amount：");
        input = new Scanner(System.in);
        money = input.nextDouble();
        if (localCard.withdrawingMoney(money)) {
            System.out.println("Withdrawals success！The card balance is ：" + localCard.getBalance());
        } else {
            System.out.println("Withdrawals failed");
        }

        /* The bank card account transfer */
        System.out.println("Now this card transfer 600 yuan to the card number 120");
        if (localCard.postMoney(nonlocalCard, 600)) {
            System.out.println("Transfer success,the card balance is ：" + localCard.getBalance());
        } else {
            System.out.println("Transfer failed");

        }
    }


}
